#include<bits/stdc++.h>
using namespace std;
int T;
int n;
int a[200010];
int ans=0;
void dfs(int x,int goal,bool yanse,int red,int blue){
    if(x==n+1){
        ans=max(goal,ans);
        return;
    }
    else {
        if(yanse){
            if(a[red]==a[x]){
                goal+=a[red];
            }
            dfs(x+1,goal,0,x,blue);
            dfs(x+1,goal,1,x,blue);
        }
        else{
            if(a[blue]==a[x]){
                goal+=a[blue];
            }
            dfs(x+1,goal,0,red,x);
            dfs(x+1,goal,1,red,x);
        }
        return;
    }
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    memset(a,0,sizeof(a));
    while(T--){
        cin>>n;
        memset(a,0,sizeof(a));
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        dfs(1,0,0,0,0);
        cout<<ans<<endl;
    }
    return 0;
}
